#ifndef DYNAMIC_TYPE_MANAGER_H
#define DYNAMIC_TYPE_MANAGER_H

#include "../types/colorset.h"
#include "../types/enumeration.h"
#include "../types/wfnettypes.h"

#include <type.h>

#include <QtCore/QHash>
#include <QtCore/QPair>
#include <QtCore/QSet>

using namespace core;

namespace wfnet
{
class WfNet;

class DynamicTypeManager
{
    typedef QPair<ColorSetName, const WfNet*const> CombinedKey;

public:
    static DynamicTypeManager* getInstance();
    static void destroy();

    void registerColorSet(const ColorSetName& name, const ValueType& type,
        WfNet* net, bool isTimed = false);
    void registerVariable(const VariableName& name, const ColorSetName& type,
        WfNet* net);

    void unregisterColorSet(const ColorSetName& name, WfNet* net);
    void unregisterVariable(const VariableName& name, WfNet* net);

    const ColorSet* getColorSet(const ColorSetName& name,
        const WfNet*const net) const;
    const Type* getVariable(const VariableName& name,
        const WfNet*const net) const;

private:
    DynamicTypeManager();
    ~DynamicTypeManager();

private:
    QHash<CombinedKey, QString> m_registeredColorSets;
    QHash<CombinedKey, QString> m_registeredVariables;
};

} // namespace wfnet

#endif
